<template>
	<view class="my">
		<view class="my_head">
			<view class="head_left" @click="todongtai">
				<image class="head_avatar" :src="userInfo.user.avatar[0]" mode=""></image>
				<view class="head_content">
					<text class="head_title">{{userInfo.user.nickname}}</text>
					<view class="conetnt">
						<view class="sex_age">
							<image class="sex_icon"
								:src="userInfo.user.sex==1 ? '/static/new/man-icon.png' : '/static/new/woman-icon.png' "
								mode=""></image>
							<text>{{userInfo.user.age || ''}}</text>
						</view>
						<view class="user_id">ID:{{userInfo.user.id}}</view>
					</view>
				</view>
			</view>
			<view class="head_right" @click="toEdit">
				<image class="edit_icon" src="/static/new/edit-icon.png" mode=""></image>
				<text>编辑</text>
			</view>
		</view>

		<view class="introduction">
			{{userInfo.user.personal_signature ? userInfo.user.personal_signature : '差一句简介,有趣的灵魂就会被发现呦~'}}
		</view>

		<view class="line"></view>

		<view class="list">
			<view class="item" @click="toPage(url,userInfo.follow)">
				<text class="item_top">{{userInfo.follow}}</text>
				<text class="item_bottom">关注</text>
			</view>
			<view class="item" @click="toPage3(url,userInfo.fans)">
				<text class="item_top">{{userInfo.fans}}</text>
				<text class="item_bottom">粉丝</text>
			</view>
			<view class="item" @click="toPage4(url,userInfo.visitor)">
				<text class="item_top">{{userInfo.visitor}}</text>
				<text class="item_bottom">访客</text>
			</view>
			<view class="item" @click="toPage5(url,userInfo.footprint)">
				<text class="item_top">{{userInfo.footprint}}</text>
				<text class="item_bottom">足迹</text>
			</view>
		</view>

		<view class="vip" @click="toGetVip">
			<image class="vip-image" src="/static/new/vip.png" mode="widthFix"></image>
		</view>

		<view class="tool CommonlyUsed">
			<view class="tool_head">
				<view class="head_line" />
				<text>常用工具</text>
			</view>
			<view class="tool_list">
				<view class="tool_item" @click="toActivity">
					<image class="item_image1 icon" src="/static/new/activity-icon.png" mode="widthFix"></image>
					<text>我的活动</text>
				</view>
				<view class="tool_item" @click="toPage2">
					<image class="item_image2 icon" src="/static/new/dynamic-icon.png" mode="widthFix"></image>
					<text>我的动态</text>
				</view>
				<view class="tool_item" @click="yaoqing1(userInfo)">
					<image class="item_image3 icon" src="/static/new/invite-icon.png" mode="widthFix"></image>
					<text>邀请好友</text>
				</view>
				<view class="tool_item" @click="toReal">
					<image class="item_image4 icon" src="/static/new/realName-icon.png" mode="widthFix"></image>
					<text>高级认证</text>
				</view>
			</view>
		</view>

		<view class="tool Necessary">
			<view class="tool_head">
				<view class="head_line" />
				<text>必备工具</text>
			</view>
			<view class="tool_list">
				<view class="tool_item" @click="toMyBack">
					<image class="item_image1 icon" src="/static/new/wallet-icon.png" mode="widthFix"></image>
					<text>我的钱包</text>
				</view>
				<view class="tool_item" @click="toHelp">
					<image class="item_image2 icon" src="/static/new/feedback-icon.png" mode="widthFix"></image>
					<text>帮助反馈</text>
				</view>
				<view class="tool_item" @click="updateFun">
					<image class="item_image3 icon" src="/static/2021-08-30/69ab5a12180f3419371350fbb353cbc.png"
						mode="widthFix"></image>
					<text>版本更新</text>
				</view>
				<view class="tool_item" @click="toSet">
					<image class="item_image4 icon" src="/static/new/set-icon.png" mode="widthFix"></image>
					<text>我的设置</text>
				</view>
			</view>
		</view>

		<voiceChatModal></voiceChatModal>
		<video-chat></video-chat>

		<pay-pop ref="payPop" />
	</view>
</template>

<script>
	import PayPop from '@/components/pay-pop/pay-pop.vue'
	export default {
		components: {
			PayPop
		},
		data() {
			return {
				userInfo: {
					user: {
						avatar: '',
						isVip: '',
					}
				},
				backState: 2,
				payState: 2
			}
		},
		onShow() {
			this.getData()
			this.$checkIsVip()
			this.isVip = uni.getStorageSync('vipInfo')
			this.$switchInfo(2).then(res => {
				this.backState = res.config_status
			})
			this.$switchInfo(3).then(res => {
				this.payState = res.config_status
			})
		},

		methods: {
			showPayPop() {
				this.$refs.payPop.open()
			},
			toDownload() {
				uni.navigateTo({
					url: "/pages/my/download"
				})
			},
			toActivity() {
				uni.navigateTo({
					url: '/pageA/my-activities/my-activities'
				})
			},
			updateFun() {
				uni.showToast({
					title: '已是最新版本，无需更新',
					icon: 'none'
				});
			},
			toGetVip() {
				uni.navigateTo({
					url: "../../pageA/vip-center/vip-center"
				})
			},
			toPage3(url, total) {
				if (total == 0) {
					uni.navigateTo({
						url: '/pages/my/fensiKong'
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/fensi?total=' + total
					})
				}
			},
			toPage4(url, total) {
				if (total == 0) {
					uni.navigateTo({
						url: '/pages/my/fangkeKong'
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/fangke?total=' + total
					})
				}
			},
			toPage5(url, total) {
				if (total == 0) {
					uni.navigateTo({
						url: '/pages/my/zujiKong'
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/zuji?total=' + total
					})
				}
			},
			toPage2() {
				uni.navigateTo({
					url: '/pages/my/myActive?id=' + uni.getStorageSync('userId')
				})
			},
			yaoqing1(e) {
				uni.navigateTo({
					url: "../../pageA/fen-xiang/fen-xiang"
				})
			},
			yaoqing(e) {
				let title = '一起来约';
				let miaoshu = '我在这里等你';
				let imgurl = e.user.avatar[0];
				let url = e.user.avatar[0];

				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 0,
					href: url,
					title: title,
					summary: miaoshu,
					imageUrl: imgurl,
					success: function(res) {
						uni.showToast({
							title: '已分享',
							duration: 2000
						});
					},
					fail: function(err) {}
				})
			},
			getData() {
				let that = this
				this.$utils.request("/api/user_center/index", {}, function(res) {
					if (res.code == 200) {
						res.data.user.avatar = JSON.parse(res.data.user.avatar)
						that.userInfo = res.data
					}
				})
			},
			todongtai() {
				uni.navigateTo({
					url: '/pages/my/mydongtai?id=' + this.userInfo.user.id
				})
			},
			tomyPage(item) {
				uni.navigateTo({
					url: '/pages/my/mydongtai?id=' + uni.getStorageSync('userId')
				})
			},
			toPage(url, total) {
				if (total == 0) {
					uni.navigateTo({
						url: '/pages/my/guanzhuKong'
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/guanzhu?total=' + total
					})
				}
			},
			toEdit() {
				uni.navigateTo({
					url: '/pages/my/edit'
				})
			},
			toReal() {
				uni.navigateTo({
					url: '/pageA/advanced-certification/advanced-certification'
				})
			},
			toMyBack() {
				uni.navigateTo({
					url: "myBack/index/index"
				})
			},
			toVoichat() {
				uni.navigateTo({
					url: "../TRTC/TRTC"
				})
			},
			toDynamic() {
				uni.navigateTo({
					url: '/pages/my/dynamic'
				})
			},
			toData() {
				uni.navigateTo({
					url: '/pages/my/data'
				})
			},
			toChat() {
				uni.navigateTo({
					url: '/pages/my/chat'
				})
			},
			toVisitor() {
				uni.navigateTo({
					url: '/pages/my/visitor'
				})
			},
			toHelp() {
				uni.navigateTo({
					url: '/pages/my/help'
				})
			},
			toSet() {
				uni.navigateTo({
					url: '/pages/my/set'
				})
			}

		}
	}
</script>

<style scoped lang="scss">
	.my_head {
		margin-top: 140upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 30upx;
		box-sizing: border-box;

		.head_left {
			display: flex;
			align-items: center;

			.head_avatar {
				width: 134upx;
				height: 134upx;
				border-radius: 50%;
				margin-right: 16upx;
			}

			.head_content {
				.head_title {
					font-size: 30upx;
					font-weight: 800;
					color: #282633;
				}

				.conetnt {
					margin-top: 20upx;
					display: flex;
					align-items: center;
				}

				.sex_age {
					width: 76upx;
					height: 45upx;
					background: linear-gradient(-90deg, #F9A8BB, #FD7199);
					border-radius: 23upx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 18upx;
					color: #FFFFFF;

					.sex_icon {
						width: 16upx;
						height: 16upx;
						margin-right: 5upx;
					}
				}

				.user_id {
					margin-left: 15upx;
					padding: 0 20upx;
					box-sizing: border-box;
					height: 46upx;
					line-height: 46upx;
					background: #F4F5F7;
					font-size: 18upx;
					color: #5F5D6A;
					border-radius: 23upx;
				}
			}
		}

		.head_right {
			width: 126upx;
			height: 55upx;
			background: linear-gradient(91deg, #FFD800, #FFA300);
			border-radius: 28upx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 26upx;
			font-weight: 500;
			color: #FFFFFF;

			.edit_icon {
				width: 27upx;
				height: 23upx;
				margin-right: 10upx;
			}
		}
	}


	.introduction {
		margin-top: 25upx;
		padding: 0 30upx;
		margin-left: 160upx;
		font-size: 26upx;
		color: #9C9AA8;
	}

	.line {
		margin-top: 38upx;
		width: 100%;
		height: 16upx;
		background: #F4F5F7;
	}

	.list {
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		padding: 45upx 0;
		box-sizing: border-box;

		.item {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.item_top {
				font-size: 47upx;
				font-weight: 800;
				color: #282633;
			}

			.item_bottom {
				margin-top: 34upx;
				font-size: 26upx;
				color: #95949A;
			}
		}
	}

	.vip {
		padding: 0 30upx;
		box-sizing: border-box;

		.vip-image {
			width: 100%;
		}
	}

	.tool {
		padding: 0 30upx;
		box-sizing: border-box;

		.tool_head {
			display: flex;
			align-items: center;
			font-size: 32upx;
			color: #1F1C2F;
			margin-bottom: 40upx;

			.head_line {
				width: 9upx;
				height: 24upx;
				background: #35B0FA;
				border-radius: 5upx;
				margin-right: 14upx;
			}
		}

		.tool_list {
			display: grid;
			grid-template-columns: repeat(4, 1fr);

			.tool_item {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				font-size: 26upx;
				color: #454545;

				.icon {
					margin-bottom: 22upx;
				}
			}
		}
	}


	.CommonlyUsed {
		margin-top: 42upx;

		.item_image1 {
			width: 41upx;
		}

		.item_image2 {
			width: 43upx;
		}

		.item_image3 {
			width: 43upx;
		}

		.item_image4 {
			width: 40upx;
		}
	}

	.Necessary {
		margin-top: 60upx;

		.item_image1 {
			width: 44upx;
		}

		.item_image2 {
			width: 44upx;
		}

		.item_image3 {
			width: 55upx;
		}

		.item_image4 {
			width: 42upx;
		}
	}
</style>
